package com.qd.pandaparkflow.compment.charge;

import com.qd.common.panda.domain.entity.feetime.BaseFeeTimeDTO;
import com.qd.pandaparkflow.context.ChargeFeeParkTimeContext;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

import java.text.MessageFormat;

/**
 * 固定免费时长
 *
 * @author sjk
 */
@ConditionalOnProperty(prefix = "liteflow", name = "enable", havingValue = "true")
@LiteflowComponent(value = "byMinutesCmp")
@Slf4j
public class ByMinutesComponent extends NodeComponent {

    @Override
    public void process() throws Exception {
        ChargeFeeParkTimeContext context = this.getContextBean(ChargeFeeParkTimeContext.class);
        BaseFeeTimeDTO baseFeeTimeDTO = context.getFeeTimeRules().get(0);
        context.setFeeTime(baseFeeTimeDTO.getFeeTime());
        context.getPrintLog().add(MessageFormat.format("固定免费时长，钟数为[{0}]", baseFeeTimeDTO.getFeeTime()));

    }
}